home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
rbbs_pc
/
vote171a.zip
/
VOTE171A.DOC
< prev
next >
Wrap
Text File
|
1988-10-23
|
14KB
|
348 lines
*****************************************
* V O T E 1 7 1 A *
* --------------- *
* Release 1.0 *
* October 1988 *
* *
* A STARWARE PRODUCT *
* by *
* John Zimmerman *
* DARK STAR *
* (707) 429-8218 *
*****************************************
FUNCTION AND PURPOSE OF VOTE171A
--------------------------------
This is a modification to RBBS 17-1A which permits callers to vote on speci-
fic topics. A current tally of votes and percentages on each topic is main-
tained for viewing. Callers may vote only once on each topic. VOTE provides a
very quick and easy method for Sysops to determine caller preferences and
views. Prior to RBBS 171A, VOTE employed the unused 'V' command to invoke it.
'V' is now used in 171A to V)iew conference mail. Assuming that most Sysops
do not have CD ROMS, and therefore do not use the Library Menu command '@',
the code has been modified to use this command to call VOTE.
MODIFICATIONS AND FILES
-----------------------
VOTE is implemented through the VOTE subprogram added to RBBSSUB1.BAS. While
this adds to the size of RBBS code, it results in a very fast implementaion
of a Voting routine, as compared to the use of a Door. The only change required
to RBBS-PC.BAS is to replace the three lines at 1283 with the two lines
contained later in this document.
The easiest way to insert this code is to use a memory resident text editor
which has a cut and paste function. Sidekick is excellent for this purpose,
as you can mark off the code contained in this document and insert it
directly into the RBBS files. This modification was compiled using Quick-
Basic 3.0.
Critical to the operation of VOTE are the following files which you must
create. Samples of the files are included. The files are:
VOTE This is the menu of available voting ballots. It must be
created similar to MENU5. In other words, whatever number
or letter you want your caller to enter to select a ballot
must be by itself.
VOTEx Where x is a number (i.e. VOTE1). This file is the descriptive
portion of the voting ballot. It contains the title of the
ballot and a description of the issue to be voted on.
VOTECx Where x is a number (i.e. VOTEC1). This file contains the
different choices on the ballot, as well as the current
count. The format of the file must be:
"this is the name of the choice",0
The entry enclosed in quotes is the choice description. The
number after the comma is the current number of votes for that
choice. When creating this file, set all votes to 0.
You may have a maximum of 15 choices on each ballot. Make sure
that the number of the VOTECx files corresponds to the number
of the VOTEx file.
VOTUSEx This file is automatically created by the code. It is a sequen-
tial file which contains the name of each caller who voted on
a specific ballot. This file is read each time a ballot is se-
lected to prevent callers from voting more than once on the
same topic.
You can have 99 voting ballots, each ballot requiring a VOTEx, VOTECx and a
VOTEUSEx file. Keep in mind that deletion of ballots will require erasing
3 files and changing VOTE - therefore, it is recommended that you keep the
number of different ballots to a minimum. Note that IBM and ANSI graphics
VOTE and VOTEx files can be created by adding G and C at the end as with
other RBBS text files. For example, VOTE9C is an ANSI display of Ballot 9.
In addition to the files described, you will want to modify MENU2 to change
@)Library to @)Vote. You may also wish to replace the '@' with a different
command through CONFIG. '$' may be a good choice, because Voting means
Elections, and Elections cost a lot of $$$$'s! You may also want to create
a M@.HLP file to explain the operation of Vote.
REPORTING PROBLEMS
------------------
Any problems or suggestions should be addressed to me as a C)omment on
DARK STAR. DARK STAR is available 24 hours per day, 7 days per week at
300/1200/2400 baud. Keep your modem on autodial - DARK STAR supports
on-line games and the line is quite busy.
CREDITS
-------
The idea for VOTE and its basic operation is derived from the DIMENSI BBS
written by Carey Nachenberg and Gregory Bass. Their source code was studied,
changed and enhanced for operation in RBBS. I'd also like to express my
appreciation to Tom Mack, Ken Goosens, Jon Martin, and the other Sysops who
make RBBS what it is. While there are many good BBS packages available,
only RBBS provides the kind of flexibility and power inherent in software
which allows you to modify the source code.
BUGS, FIXES AND ENHANCEMENTS
02/12/88 Voting on a ballot choice greater than 9 resulted in ballot choice
1 getting the vote because in line 64720 the variable B$, which
contained the number of the selection being voted on, only had the
left most character read. Changing this to LEFT$(B$,2) allows ballot
choices greater than 9 to get the vote.
A line showing the total votes in a specific ballot was added.
05/15/88 Documentation updated for compatibility with RBBS 16-1A.
10/23/88 Code modified for RBBS 17-1A. Eliminates ability to use the
@)Library command. Also includes addition of TurboKey patches
to make it work consistently with the rest of RBBS.
MODIFICATIONS TO RBBS SOURCE CODE
-----------------------------------------------------------------------------
TO RBBS-PC.BAS: Apply the changes/additions identified by ' Vote
-----------------------------------------------------------------------------
1270 Z$ = B$(ANS.INDEX)
CALL ALLCAPS (Z$)
IF Z$ = "C" THEN _
Z$ = "M" : _
GOTO 5323
ON INSTR(QUIT.LIST$,Z$) GOTO 1275,1280,1285,10570,1283
GOTO 1260
1275 MENU.INDEX = 3
GOTO 1295
1280 MENU.INDEX = 2
GOTO 1295
1283 CALL VOTE(ACTIVE.USER.NAME$,USER.GRAPHIC.DEFAULT$) 'Vote
RETURN 'Vote
'1283 MENU.INDEX = 6 'Vote
' ACTIVE.FMS.DIRECTORY$ = "" 'Vote
' GOTO 1295 'Vote
1285 MENU.INDEX = 4
1295 CALL SETSECT
RETURN
1300 CALL QTPUT ("Message base " + GRN$,1)
RETURN
-----------------------------------------------------------------------------
TO RBBSSUB1.BAS: Add the VOTE subprogram after the PUTWORK subprogram at
line 59660 and before the Error handling routines beginning
at 65000
-----------------------------------------------------------------------------
59660 SUB PUTWORK (STRNG$,REC.NUM,REC.LEN) STATIC
ON ERROR GOTO 65000
FIELD #2,REC.LEN AS UPLOAD.RECORD$
LSET UPLOAD.RECORD$ = STRNG$
REC.NUM = REC.NUM + 1
PUT #2,REC.NUM
END SUB
' $SUBTITLE: 'VOTE -- subroutine for voting'
' $PAGE
'
' SUBROUTINE NAME -- VOTE By John Zimmerman
' DARK STAR (707) 429-8218
'
' INPUT PARAMETERS -- PARAMETER MEANING
'
' ACTIVE.USER.NAME$ NAME OF THE CURRENT USER
' USER.GRAPHIC.DEFAULT$ USER'S GRAPHICS SETTING
'
' OUTPUT PARAMETERS -- NONE
'
' SUBROUTINE PURPOSE -- TO DISPLAY A VOTING BALLOT, CAPTURE AND SAVE THE
' USER'S VOTE.
'
SUB VOTE (ACTIVE.USER.NAME$,GRAPHIC.DEFAULT$) STATIC
REDIM CHOICE$(15),CHOICE.TOTAL(15)
' *****************************************************************************
' * OPEN THE VOTE MENU FILE AND DISPLAY AVAILABLE VOTING BALLOTS *
' *****************************************************************************
64700 FILE.NAME$ = "VOTE"
STOP.INTERRUPTS = FALSE
CALL GRAPHIC (GRAPHIC.DEFAULT$)
CALL BUFFILE (FILE.NAME$,X)
IF NOT OK THEN _
CALL QTPUT("No voting ballots are available",1) : _
EXIT SUB
A$ = "Vote on which ballot (Press [ENTER] to quit)"
SUBROUTINE.PARAMETER = 1
CALL TGET
IF B$ = "" THEN _
EXIT SUB
ANS.INDEX = 1
Z$ = B$(ANS.INDEX)
CALL WORDINFILE (FILE.NAME$,Z$,FOUND)
IF NOT FOUND THEN _
CALL QTPUT ("No such ballot "+Z$,1) : _
GOTO 64700
FILE.NAME$ = "VOTE" + Z$
STOP.INTERRUPTS = FALSE
CALL GRAPHIC (GRAPHIC.DEFAULT$)
CALL BUFFILE (FILE.NAME$,X)
IF NOT OK THEN _
CALL UPDTCALR ("Missing ballot " + Z$,2) : _
CALL QTPUT ("Ballot (" + Z$ + ") is not available.",1) : _
GOTO 64700
VOTE.COUNT$ = "VOTEC" + Z$
VOTE.USER$ = "VOTUSE" + Z$
' *****************************************************************************
' * OPEN THE VOTE.COUNT$ FILE TO GET THE CHOICES AND COUNTS *
' *****************************************************************************
64705 CLOSE 2
OPEN VOTE.COUNT$ FOR INPUT AS #2
CHOICES = 0
I = 0
DO WHILE NOT EOF(2)
I = I + 1
IF I > 15 THEN _
EXIT DO
INPUT #2, CHOICE$(I),CHOICE.TOTAL(I)
CHOICE$(I) = LEFT$(CHOICE$(I),55)
CHOICES = I
LOOP
CLOSE 2
' *****************************************************************************
' * OPEN THE VOTE.USER$ FILE TO CHECK FOR PREVIOUS VOTE BY THE CALLER *
' *****************************************************************************
64710 FILE.NAME$ = VOTE.USER$
CALL FINDIT(FILE.NAME$)
IF NOT OK THEN _
GOTO 64715
CLOSE 2
OPEN VOTE.USER$ FOR INPUT AS #2
VOTED = 0
DO WHILE NOT EOF(2)
INPUT #2, I$
IF ACTIVE.USER.NAME$ = I$ THEN
VOTED = 1
EXIT DO
END IF
LOOP
CLOSE 2
IF VOTED = 1 THEN
A$ = "You already voted on this ballot. See the results ([Y],N)"
SUBROUTINE.PARAMETER = 1
CALL TGET
IF LEFT$(B$,1) = "N" or B$ = "n" THEN _
GOTO 64700
GOTO 64725
END IF
' *****************************************************************************
' * DISPLAY THE BALLOT *
' *****************************************************************************
64715 CALL QTPUT ("Ballot choices (Vote 0 to quit without voting)",2)
FOR I = 1 TO CHOICES
I$ = "(" + RIGHT$(STR$(I),LEN(STR$(I))-1) + ") "
CALL QTPUT(I$ + CHOICE$(I),1)
NEXT
CALL QTPUT ("------------------------------------------------------",1)
' *****************************************************************************
' * GET THE CALLER'S VOTE *
' *****************************************************************************
64720 A$ = "Your vote (1 -" + STR$(CHOICES) + " )"
SUBROUTINE.PARAMETER = 1
CALL TGET
VOTE = VAL(LEFT$(B$,2))
IF VOTE = 0 THEN _
EXIT SUB
IF VOTE > CHOICES THEN _
CALL QTPUT ("Incorrect choice. Try again ...",1): _
GOTO 64720
OPEN VOTE.USER$ FOR APPEND AS #2
WRITE #2, ACTIVE.USER.NAME$
CLOSE 2
CHOICE.TOTAL(VOTE) = CHOICE.TOTAL(VOTE) + 1
' *****************************************************************************
' * UPDATE THE VOTE COUNT, DISPLAY RESULTS, AND UPDATE VOTE.COUNT$ FILE *
' *****************************************************************************
64725 TOTAL.VOTES = 0
FOR I = 1 TO CHOICES
TOTAL.VOTES = TOTAL.VOTES + CHOICE.TOTAL(I)
NEXT
CALL QTPUT ("Current Voting Results:" + SPACE$(40) + "Votes Pct ",1)
CALL QTPUT ("-----------------------" + SPACE$(40) + "----- -----",1)
FOR I = 1 TO CHOICES
I$ = "[" + RIGHT$(STR$(I),LEN(STR$(I))-1) + "]"
I$ = I$ + SPACE$(5-(LEN(I$)))
I$ = I$ + CHOICE$(I) + SPACE$(56-LEN(CHOICE$(I)))
I$ = I$ + SPACE$(6-LEN(STR$(CHOICE.TOTAL(I))))
I$ = I$ + STR$(CHOICE.TOTAL(I))
IF CHOICE.TOTAL(I) > 0 THEN
J$ = STR$(INT((CHOICE.TOTAL(I)/TOTAL.VOTES)*100)) + "%"
ELSE
J$ = STR$(0) + "%"
END IF
I$ = I$ + SPACE$(7-LEN(J$)) + J$
CALL QTPUT (I$,1)
NEXT
CALL QTPUT ("",1)
CALL QTPUT ("Total votes on this ballot = " + STR$(TOTAL.VOTES),1)
CALL QTPUT ("",1)
OPEN VOTE.COUNT$ FOR OUTPUT AS #2
FOR I = 1 TO CHOICES
WRITE #2, CHOICE$(I), CHOICE.TOTAL(I)
NEXT
CLOSE 2
A$ = "Vote on another ballot ([Y],N)"
SUBROUTINE.PARAMETER = 1
CALL TGET
IF B$ = "n" OR B$ = "N" THEN _
EXIT SUB
GOTO 64700
END SUB ' END OF VOTE SUBPROGRAM
' $SUBTITLE: 'Error Handling for separately compiled subroutines'
' $PAGE
'
' *****************************************************************************
' * Error handling for the separately compiled subroutines of RBBS-PC *
' *****************************************************************************
'
65000 IF DEBUG THEN _
------------------------------- END OF VOTE171A.DOC ---------------------------